package com.wyl.salary.ui.components

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wyl.salary.ui.theme.SalaryTheme

@Composable
fun AddSalary(
    date: String,
    hours: String,
    salary: String,
    tipping: String,
    remarks: String,
    onDateChange: (String) -> Unit,
    onHoursChange: (String) -> Unit,
    onSalaryChange: (String) -> Unit,
    onTippingChange: (String) -> Unit,
    onRemarksChange: (String) -> Unit,
    modifier: Modifier = Modifier
) {
    Column(
        modifier = modifier
            .fillMaxWidth()
            .padding(16.dp)
    ) {
        OutlinedTextField(
            value = date,
            onValueChange = onDateChange,
            label = { Text(text = "日期") },
            modifier = Modifier.fillMaxWidth(),
            placeholder = { Text(text = "请输入日期") },
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Phone,
                imeAction = ImeAction.Next,
            ),
            singleLine = true
        )
        Spacer(modifier = Modifier.height(8.dp))
        OutlinedTextField(
            value = hours,
            onValueChange = onHoursChange,
            label = { Text(text = "工作时长") },
            placeholder = { Text(text = "请输入工作时长") },
            modifier = Modifier.fillMaxWidth(),
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Number,
                imeAction = ImeAction.Next,
            ),
            singleLine = true
        )
        Spacer(modifier = Modifier.height(8.dp))
        OutlinedTextField(
            value = salary,
            onValueChange = onSalaryChange,
            label = { Text(text = "时薪") },
            placeholder = { Text(text = "请输入时薪") },
            modifier = Modifier.fillMaxWidth(),
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Number,
                imeAction = ImeAction.Next,
            ),
            singleLine = true
        )
        Spacer(modifier = Modifier.height(8.dp))
        OutlinedTextField(
            value = tipping,
            onValueChange = onTippingChange,
            label = { Text(text = "外卖费") },
            placeholder = { Text(text = "请输入外卖费") },
            modifier = Modifier.fillMaxWidth(),
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Number,
                imeAction = ImeAction.Next,
            ),
            singleLine = true
        )
        Spacer(modifier = Modifier.height(8.dp))
        OutlinedTextField(
            value = remarks,
            onValueChange = onRemarksChange,
            label = { Text(text = "备注") },
            placeholder = { Text(text = "请输入备注内容") },
            modifier = Modifier.fillMaxWidth(),
            keyboardOptions = KeyboardOptions(
                imeAction = ImeAction.Done,
            ),
            maxLines = 5,
        )
    }
}


@Preview(showBackground = true)
@Composable
fun PreviewAddSalary() {
    SalaryTheme {
        AddSalary(
            "date", "hours", "salary", "tipping", "remakes",
            onDateChange = { },
            onHoursChange = {},
            onSalaryChange = {},
            onTippingChange = {},
            onRemarksChange = {}
        )
    }
}